<?php

require_once 'data\datautils.php';
require_once 'helpers\url_helper.php';

$method_map = array(
"" => "index",
"add" => "add"
);

include("baseController.php");

function index() {
	showView('products',array('title' => 'Products','products' => db_select_all('products')));
}

function add() {
	global $req;
	db_insert('products',array("category_id" => (int)$req['category_id'],"name" => "'".$req['name']."'","code"=>"'".$req['code']."'","small_desc"=>"'".$req['small_desc']."'","full_desc"=>"'".$req['full_desc']."'","Created_At"=>"NOW()"));
	header('Location: '.get_url('products',null,array()));
}